using System;
using System.Collections.Generic;
using System.Text;
using AllegNet;

namespace DemonHunter
{
    class LightneningBolt:Entity
    {
        //data
        private static Bmp myBitmap;
        private DateTime start;
        private int phase = 0;

        //constructor
        public LightneningBolt()
        {
            Random rnd = new Random();

            entityYLoc = -20;
            entityXLoc = Logic.GetInstance().GetXLoc() + rnd.Next(1024 - myBitmap.Width);
        }


        //overridden functions
        //don't allow ai to move lightning bolt
        public override void move() { }

        public override void DoXIncrease()
        {
            entityXLoc += 5 * speedModifier;
        }

        public override void animate()
        {
            if (phase == 0)
            {
                Sound.playSound(Sound.SOUND_LIGHTNING);
                start = DateTime.Now;
                phase = 1;
            }
            DateTime stop = DateTime.Now;
            TimeSpan delay = stop - start;
            if (delay.Milliseconds >= 100)
            {
                phase++;
                if (phase == 2) entityYLoc = -300;
                else if (phase == 3) entityYLoc = -20;
                else if (phase == 4)
                {
                    
                    Level.GetInstance().RemoveEntity(this);
                }
                start = DateTime.Now;
            }
        }
        /// <summary>
        /// return current bitmap
        /// </summary>
        /// <returns></returns>
        public override Bmp GetCurrentBitmap()
        {
            return myBitmap;
        }
        /// <summary>
        /// load bitmaps into memory
        /// </summary>
        public new static void LoadBitmaps()
        {
            myBitmap = Game.GetInstance().LoadBitmap("C:\\DemonHunterart\\props\\bolt.bmp");
        }
        /// <summary>
        /// return current bitmap height
        /// </summary>
        /// <returns></returns>
        public override double GetCurrentBitmapHeight()
        {
            return myBitmap.Height;
        }
    }

}
